package br.ufu.comp.pdi;

public class Teste{
    public static ImageData RGB2Gray(ImageData im){		
		ImageData im1 = new ImageData(im.altura(), im.largura(), 1, ImageData.CINZA);
		int v;
		for(int y = 0; y < im.altura(); y++ ){
			for(int x = 0; x < im.largura(); x++ ){
				v = (int) (im.get(y,x,0) + im.get(y,x,1) + im.get(y,x,2))/3;
				im1.set(y,x,v);
			}
		}
		return im1;
	}
	
}